
package ListHandling;

import basic.Client;
import exceptions.ObjectNotFound;
import java.util.Scanner;
import lists.Lists;

public class ClientListHandling {
    // dopiero przy finalizowaniu transakcji count danego klienta inkremantujemy !!
    public static Scanner in = new Scanner(System.in);
       
    public static Client addClient() {
        // i dont check if the entered date is propriet !
        Client helper = new Client();
        System.out.println("Name: ");
        helper.setName(in.next());
        System.out.println("Surname: ");
        helper.setSurname(in.next());
        return helper;
    }
    
    public static void showClientList() {
        System.out.println("CLIENT LIST\n");
        System.out.println(String.format("%4s %20s %20s %15s", "ID",
                "NAME", "SURNAME", "RESERV. COUNT"));
        System.out.println();
        Lists.cList.show();
        
    }
    
    public static void deleteClient() throws ObjectNotFound {
        System.out.println("Enter ID of client you want to delete: ");
        int p = in.nextInt();
        if (Lists.cList.ifExist(p)<0 ) throw new ObjectNotFound();
        else Lists.cList.delete(p);
        System.out.println("Successfully deleted client !");
    }
    
    public static void sortClientList(){
        Lists.cList.sort();
        System.out.println("Successfully sorted!");
    }
    
    public static void fill(){
        Client c1 = new Client();
        c1.setName("dominik");
        c1.setSurname("szczygiel");
        Client c2 = new Client();
        c2.setName("adam");
        c2.setSurname("gontarz");
        
        Lists.cList.add(c1);
        Lists.cList.add(c2);
        
    }
    
}
